package com.supermarket_project.controller;

import com.supermarket_project.common.R;
import com.supermarket_project.pojo.Staff;
import com.supermarket_project.service.StaffService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * Created with IntelliJ IDEA.
 * User: ljc
 * Date: 2022/07/07 9:20
 * Description:
 * Version: V1.0
 */
@RequestMapping("/supermarket")
@RestController
@CrossOrigin //解决了跨域问题
public class StaffController {
    @Autowired
    private StaffService staffService;

    @GetMapping(value = "/staffSelect")
    public R staffSelect(Integer page, Integer limit, Integer staff_id) {
        return staffService.staffSelect(page, limit, staff_id);
    }

    @PostMapping(value = "/loginStaff")
    public R logingStaff(@RequestBody Staff staff) {
        return staffService.loginstaff(staff.getStaff_id(), staff.getPassword());
    }

    @PostMapping(value = "/addStaff")
    public R addStaff(@RequestBody Staff staff) {
        return staffService.addStaff(staff);
    }

    @PostMapping(value = "delStaff")
    public R delStaff(@RequestBody Staff staff) {
        return staffService.delStaff(staff.getStaff_id());
    }

    @PostMapping(value = "upStaff")
    public R upStaff(@RequestBody Staff staff){
        return staffService.upStaff(staff);
    }

    @PostMapping(value = "regStaff")
    public R regStaff(@RequestBody Staff staff){
        return staffService.regStaff(staff.getStaff_id());
    }

}
